CC = gcc
CFLAGS = -O0 -g -Wall -lrt -lm -I. -I../.. \
		-I/usr/local/include \
		-L/usr/local/lib 
CFLAGS += -D_GNU_SOURCE

all: jitter_m 

jitter_m: jitter_m.c jitter_m.o libcha.a libmatch.a
	$(CC) $(CFLAGS) -o $@ jitter_m.o -L. -lcha -L. -lmatch -lhdfw -lhdfpga -lpthread -lzlog 

libcha.a: sample_cha.o
	ar rcs $@ $^

libmatch.a: core_match.o
	ar rcs $@ $^
	
jitter_m.o: jitter_m.c sample_cha.h core_match.h
	$(CC) $(CFLAGS) -c $< -o $@

core_match.o: core_match.c core_match.h
	$(CC) -c $< -o $@

sample_cha.o: sample_cha.c sample_cha.h
	$(CC) -c $< -o $@

clean:
	rm -f jitter_m *.o *.a

remake:
	make clean
	make
	
.PHONY: all clean remake

